#!/usr/bin python3
# -*- coding: utf-8 -*-

import logging

sum = input()
s1 = [int(i) for i in input().split(' ')]
s2 = [int(i) for i in input().split(' ')]

temp = []
for i in range(len(s2)):
    j = 0
    while j < len(s1):
        if s1[i] == s2[j]:
            if len(temp) == 0 or (len(temp) > 0 and j > temp[-1][1]):
                temp.append([s2[i], j])
        j += 1

print(len(s2) - len(temp))
